package PTA_05_24;

import java.util.Scanner;

public class Main4 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String flag = sc.next();
        String str = sc.nextLine();
        str.trim();
        String[] strs = str.split(" ");
        int Count = 0;
        for (int i = 1; i < strs.length; i++) {
            StringBuffer sb = new StringBuffer();
            sb.append(strs[i]);
            String sub = sb.substring(0,1);
            if(sub.equals(flag))
                Count++;
        }
        System.out.println(Count);
    }
}
